package com.boot.security.server.dao.product;

import java.util.List;
import java.util.Map;

import com.boot.security.server.model.dto.TswproductViews;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.product.TswProduct;

@Mapper
public interface TswProductDao {

    @Select("select * from tsw_product t where t.id = #{id}")
    TswProduct getById(Long id);

    @Delete("delete from tsw_product where id = #{id}")
    int delete(Long id);

    int update(TswProduct tswProduct);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_product(product_no, product_name, product_details, classify_ids, brand_id, state, unsold_inventory_all, undistributed_inventory_all, virtual_sales, sales, product_photo_id, shuffling_figure_ids, details_figure_path_ids, viewed_times, create_time, tsw_sys_user_id, update_time, updater, product_note, product_remark) values(#{productNo}, #{productName}, #{productDetails}, #{classifyIds}, #{brandId}, #{state}, #{unsoldInventoryAll}, #{undistributedInventoryAll}, #{virtualSales}, #{sales}, #{productPhotoId}, #{shufflingFigureIds}, #{detailsFigurePathIds}, #{viewedTimes}, #{createTime}, #{sysUserId}, #{updateTime}, #{updater}, #{productNote}, #{productRemark})")
    int save(TswProduct tswProduct);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswProduct> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    int newCount(@Param("params") Map<String, Object> params);

    List<TswproductViews> newList(@Param("params") Map<String,Object> params,@Param("offset") Integer offset,@Param("limit") Integer limit);
}
